home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performAddInfluence.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  11.0 KB  |  428 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Oct 12, 1998
  22. //
  23. //  Description:
  24. //      This script sets up the skinCluster Add Influence dialog box
  25. //
  26. //  Input Arguments:
  27. //      None.
  28. //
  29. //  Return Value:
  30. //      None.
  31. //
  32.  
  33. proc setOptionVars (int $forceFactorySettings)
  34. {
  35.     // Use Geometry
  36.     //
  37.     if( $forceFactorySettings || !`optionVar -exists useGeometry` ) {
  38.         // default useGeometry of 1 means use the geometry of the
  39.         // bound object
  40.         //
  41.         optionVar -intValue useGeometry 1;
  42.     }
  43.     
  44.     // Dropoff
  45.     //
  46.     if ( $forceFactorySettings || !`optionVar -exists dropoff` ) {
  47.         optionVar -floatValue dropoff 4.0;
  48.     }
  49.  
  50.     // Smoothness
  51.     //
  52.     if ( $forceFactorySettings || !`optionVar -exists polySmoothness` ) {
  53.         optionVar -floatValue polySmoothness 0.0;
  54.     }
  55.  
  56.     // Nurbs samples
  57.     if ( $forceFactorySettings || !`optionVar -exists nurbsSamples`) {
  58.         optionVar -intValue nurbsSamples 10;
  59.     } 
  60.  
  61.     // Lock weights
  62.     //
  63.     if ( $forceFactorySettings || !`optionVar -exists lockWeights`){
  64.         optionVar -intValue lockWeights 0;
  65.     }
  66.  
  67.     // Default weight
  68.     //
  69.     if ( $forceFactorySettings || !`optionVar -exists defaultWeight`) {
  70.         optionVar -floatValue defaultWeight 0.0;
  71.     }
  72.  
  73. }
  74.  
  75. //
  76. //  Procedure Name:
  77. //      addInfluenceSetup
  78. //
  79. //  Description:
  80. //        Update the state of the option box UI to reflect the option values.
  81. //
  82. //  Input Arguments:
  83. //      parent               - Top level parent layout of the option box UI.
  84. //                             Required so that UI object names can be 
  85. //                             successfully resolved.
  86. //
  87. //        forceFactorySettings - Whether the option values should be set to
  88. //                             default values.
  89. //
  90. //  Return Value:
  91. //      None.
  92. //
  93. global proc addInfluenceSetup (string $parent, int $forceFactorySettings)
  94. {
  95.     // Retrieve the option settings
  96.     //
  97.     setOptionVars( $forceFactorySettings );
  98.     
  99.     setParent $parent;
  100.     
  101.     // Query the optionVar's and set the values into the controls
  102.     //
  103.     int $useGeom = `optionVar -query useGeometry`;
  104.     checkBoxGrp -e -value1 $useGeom useGeometryWidget;
  105.  
  106.     // Dropoff
  107.     //
  108.     if (`floatSliderGrp -exists dropoff`){
  109.         floatSliderGrp -edit
  110.             -value `optionVar -query dropoff`
  111.             dropoff;
  112.     }
  113.  
  114.     // Poly smoothness
  115.     //
  116.     if (`floatSliderGrp -exists psWidget`){
  117.         floatSliderGrp -edit
  118.             -value `optionVar -query polySmoothness`
  119.             psWidget;
  120.         if ($useGeom)
  121.             floatSliderGrp -e -enable 1 psWidget;
  122.     }
  123.  
  124.     // Nurbs samples
  125.     //
  126.     if (`intSliderGrp -exists nsWidget`) {
  127.         intSliderGrp -edit
  128.             -value `optionVar -query nurbsSamples`
  129.             nsWidget;
  130.         if ($useGeom)
  131.             intSliderGrp -e -enable 1 nsWidget;
  132.     }
  133.  
  134.     // lock weights
  135.     //
  136.     int $lockWts = `optionVar -query lockWeights`;
  137.     checkBoxGrp -e -value1 $lockWts lockWeightsWidget;
  138.  
  139.     // default weight
  140.     //
  141.     if (`floatSliderGrp -exists defaultWeightWidget`) {
  142.         floatSliderGrp -edit
  143.             -value `optionVar -query defaultWeight`
  144.             defaultWeightWidget;
  145.         
  146.         floatSliderGrp -e -enable $lockWts defaultWeightWidget;
  147.     }
  148.    
  149.  
  150.     
  151. }
  152.  
  153.  
  154. //
  155. //  Procedure Name:
  156. //      addInfluenceCallback
  157. //
  158. //  Description:
  159. //        Update the option values with the current state of the option box UI.
  160. //
  161. //  Input Arguments:
  162. //      parent - Top level parent layout of the option box UI.  Required so
  163. //               that UI object names can be successfully resolved.
  164. //
  165. //        doIt   - Whether the command should execute.
  166. //
  167. //  Return Value:
  168. //      None.
  169. //
  170. global proc addInfluenceCallback (string $parent, int $doIt)
  171. {
  172.     setParent $parent;
  173.     
  174.     optionVar -intValue useGeometry `checkBoxGrp -q -value1 useGeometryWidget`;
  175.  
  176.     // Dropoff
  177.     //
  178.     if (`floatSliderGrp -exists dropoff`) {
  179.         optionVar -floatValue dropoff
  180.             `floatSliderGrp -query -value dropoff`;
  181.     }
  182.  
  183.     // Poly smoothness
  184.     //
  185.     if (`floatSliderGrp -exists psWidget`) {
  186.         optionVar -floatValue polySmoothness
  187.             `floatSliderGrp -query -value psWidget`;
  188.     }
  189.  
  190.     // Nurbs samples
  191.     //
  192.     if (`intSliderGrp -exists nsWidget`) {
  193.         optionVar -intValue nurbsSamples
  194.             `intSliderGrp -query -value nsWidget`;
  195.     }
  196.  
  197.     // lock weights
  198.     //
  199.     optionVar -intValue lockWeights `checkBoxGrp -q -value1 lockWeightsWidget`;
  200.     
  201.     // default weight
  202.     //
  203.     if (`floatSliderGrp -exists defaultWeightWidget`) {
  204.         optionVar -floatValue defaultWeight
  205.             `floatSliderGrp -query -value defaultWeightWidget`;
  206.     }
  207.  
  208.  
  209.     if ($doIt) {
  210.         performAddInfluence false; 
  211.         addToRecentCommandQueue "performAddInfluence false" "AddInfluence";
  212.     }
  213. }
  214.  
  215.  
  216. global proc addInfluenceOptions ()
  217. {
  218.     // Name of the command for this option box 
  219.     //
  220.     string $commandName = "addInfluence";
  221.  
  222.     // Build the option box "methods"
  223.     //
  224.     string $callback = ($commandName + "Callback");
  225.     string $setup = ($commandName + "Setup");
  226.     
  227.     //    STEP 1:  Get the option box.
  228.     //    ============================
  229.     //
  230.     //    The value returned is the name of the layout to be used as
  231.     //    the parent for the option box UI.
  232.     //
  233.     string $layout = getOptionBox();
  234.     setParent $layout;
  235.     
  236.     //    STEP 2:  Pass the command name to the option box.
  237.     //    =================================================
  238.     //
  239.     //    Any default option box behaviour based on the command name is set 
  240.     //    up with this call.  For example, updating the 'Help' menu item with
  241.     //    the name of the command.
  242.     //
  243.     setOptionBoxCommandName("skinCluster");
  244.     
  245.     //    STEP 3:  Activate the default UI template.
  246.     //    ==========================================
  247.     //
  248.     //    Activate the default UI template so that the layout of this 
  249.     //    option box is consistent with the layout of the rest of the 
  250.     //    application.
  251.     //
  252.     setUITemplate -pushTemplate DefaultTemplate;
  253.  
  254.     //    STEP 4: Create option box contents.
  255.     //    ===================================
  256.     //    
  257.     //    This, of course, will vary from option box to option box.    
  258.     
  259.     //    Turn on the wait cursor.
  260.     //
  261.     waitCursor -state 1;
  262.  
  263.     tabLayout -tabsVisible 0 -scrollable 1;
  264.     
  265.     string $parent = `columnLayout -adjustableColumn 1`;
  266.  
  267.     checkBoxGrp
  268.         -label "Geometry"
  269.         -label1 "Use Geometry"
  270.         -numberOfCheckBoxes 1
  271.          -on1 "floatSliderGrp -e -enable 1 psWidget; intSliderGrp -e -enable 1 nsWidget"
  272.          -of1 "floatSliderGrp -e -enable 0 psWidget; intSliderGrp -e -enable 0 nsWidget"
  273.         useGeometryWidget;
  274.  
  275.     floatSliderGrp -label "Dropoff" -minValue 0.1 -maxValue 10.0 -fieldMaxValue 100.0 -pre 1 dropoff ;
  276.  
  277.     floatSliderGrp -label "Polygon Smoothness" -minValue 0.0 -maxValue 50.0 -enable (`checkBoxGrp -q -v1 useGeometryWidget`) -pre 1 psWidget;
  278.  
  279.     intSliderGrp -label "NURBS Samples" -minValue 1 -maxValue 100 -enable (`checkBoxGrp -q -v1 useGeometryWidget`) nsWidget;
  280.  
  281.     checkBoxGrp
  282.         -label "Weight Locking"
  283.         -label1 "Lock Weights"
  284.         -numberOfCheckBoxes 1
  285.          -on1 "floatSliderGrp -e -enable 1 defaultWeightWidget"
  286.          -of1 "floatSliderGrp -e -enable 0 defaultWeightWidget"
  287.         lockWeightsWidget;
  288.  
  289.     floatSliderGrp -label "Default Weight" -minValue 0.0 -maxValue 1.0 -enable (`checkBoxGrp -q -v1 lockWeightsWidget`) -pre 3 defaultWeightWidget;
  290.  
  291.  
  292.     //    Turn off the wait cursor.
  293.     //
  294.     waitCursor -state 0;
  295.     
  296.     //    Step 5: Deactivate the default UI template.
  297.     //    ===========================================
  298.     //
  299.     setUITemplate -popTemplate;
  300.  
  301.     //    Step 6: Customize the buttons.  
  302.     //    ==============================
  303.     //
  304.     //    Provide more descriptive labels for the buttons.  This is not 
  305.     //    necessary, but in some cases, for example, a button labelled 
  306.     //    'Create' may be more meaningful to the user than one labelled
  307.     //    'Apply'.
  308.     //
  309.     //    Disable those buttons that are not applicable to the option box.
  310.     //
  311.     //    Attach actions to those buttons that are applicable to the option
  312.     //    box.  Note that the 'Close' button has a default action attached 
  313.     //    to it that will hide the window.  If a a custom action is
  314.     //    attached to the 'Close' button then be sure to call the 'hide the
  315.     //    option box' procedure within the custom action so that the option
  316.     //    box is hidden properly.
  317.  
  318.     //    'Apply' button.
  319.     //
  320.     string $applyBtn = getOptionBoxApplyBtn();
  321.     button -edit -l "Add"
  322.         -command ($callback + " " + $parent + " " + 1)
  323.         $applyBtn;
  324.  
  325.     //    'Save' button.
  326.     //
  327.     string $saveBtn = getOptionBoxSaveBtn();
  328.     button -edit
  329.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  330.         $saveBtn;
  331.  
  332.     //    'Reset' button.
  333.     //
  334.     string $resetBtn = getOptionBoxResetBtn();
  335.     button -edit 
  336.         -command ($setup + " " + $parent + " " + 1)
  337.         $resetBtn;
  338.  
  339.     //    Step 7: Set the option box title.
  340.     //    =================================
  341.     //
  342.     setOptionBoxTitle("Add Influence Options");
  343.  
  344.     //    Step 8: Customize the 'Help' menu item text.
  345.     //    ============================================
  346.     //
  347.     setOptionBoxHelpTag( "AddInfluence" );
  348.  
  349.     //    Step 9: Set the current values of the option box.
  350.     //    =================================================
  351.     //
  352.     eval (($setup + " " + $parent + " " + 0));    
  353.     
  354.     //    Step 10: Show the option box.
  355.     //    =============================
  356.     //
  357.     showOptionBox();
  358. }
  359.  
  360. proc string assembleCmd ()
  361. {
  362.     string $cmd;
  363.  
  364.     setOptionVars( false );
  365.     
  366.     $cmd = "skinClusterInfluence 1 \"";
  367.  
  368.     int $useGeometry = `optionVar -q useGeometry`;
  369.     if ($useGeometry == 1)
  370.         $cmd = $cmd + "-ug";
  371.  
  372.     $cmd += " -dr " + `optionVar -query dropoff`;
  373.  
  374.     if ($useGeometry == 1)
  375.     {
  376.         $cmd += " -ps " + `optionVar -query polySmoothness`;
  377.         $cmd += " -ns " + `optionVar -query nurbsSamples`;
  378.     }
  379.  
  380.     int $lockWeights = `optionVar -q lockWeights`;
  381.     if ($lockWeights == 1)
  382.     {
  383.         $cmd = $cmd + " -lw true -wt " + `optionVar -query defaultWeight`;
  384.     }
  385.  
  386.     $cmd += "\"";
  387.  
  388.     return $cmd;
  389. }
  390.  
  391. global proc string performAddInfluence (int $action)
  392. // The action variable means
  393. //        0 - do the command
  394. //        1 - show the option box
  395. //        2 - return the drag command
  396. //
  397. {
  398.     string $cmd = "";
  399.  
  400.     switch ($action) {
  401.         case 0: // Execute the command
  402.             // Retrieve the option settings
  403.             //
  404.             setOptionVars (false);
  405.  
  406.             // Get the command and print it in the command window
  407.             $cmd = `assembleCmd`;
  408.             
  409.             // Execute the command with the option settings
  410.             evalEcho($cmd);
  411.  
  412.             break;
  413.         case 1:  // Do the option box
  414.             addInfluenceOptions;
  415.             break;
  416.         case 2: // Return the drag string
  417.             // Retrieve the option settings
  418.             //
  419.             setOptionVars (false);
  420.  
  421.             // Get the command
  422.             $cmd = `assembleCmd`;
  423.  
  424.             break;
  425.     }
  426.     return $cmd;
  427. }
  428.